<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script type="text/javascript">
        const _isUrl = url => {
            // 补全代码
            let reg = /^((http|https):\/\/)?(([A-Za-z0-9]+-[A-Za-z0-9]+|[A-Za-z0-9]+)\.)+([A-Za-z]+)[/\?\:]?.*$/;
            return reg.test(url);
        }
        console.log(_isUrl('http://localhost:8080/abc'));;
        _isUrl('https://baidu.com');
        _isUrl('http/baidu.com');
        
    </script>
</body>
</html>